Skip to content

fix(selene): fix pool client event-loop starvation, fencing, backpressure, and overflow bugs - #611

Merged
yatesdr merged 1 commit into
NVIDIA:mainfrom
yatesdr:fix/selene-pool-client-reliability
Nov 29, 2026
Merged

yatesdr merged 1 commit into
NVIDIA:mainfrom
yatesdr:fix/selene-pool-client-reliability

Conversation

@yatesdr

@yatesdr yatesdr commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Why this change is needed

Under active traffic, disconnects, or untrusted manager metadata, the Selene pool client engine and connection loop could stall, drop required fence acknowledgments, livelock on resync, or overflow staging calculations:

  • Engine::pump_flow did not drain collect_outbound_fills(), and conn::serve created a fresh sleep(tick) on every tokio::select! iteration, starving outbound fills and periodic engine ticks while control messages arrived.
  • on_put_accept could drop FenceAck(Drained) when a PutAccept arrived late for an already-cancelled put, did not transition to Phase::Accepted before handling errors, and accepted accept.packed = true on raw puts.
  • Outbound gRPC channel saturation disconnected the session instead of applying backpressure, and session_lost dropped queued fence-class messages in self.owed.
  • staging_slots, Staging::planned_bytes, and Staging::new used unchecked arithmetic on manager-supplied limits; reconnect did not recheck max_window_bytes; conn::dial did not strip IPv6 brackets; RankAgent::wind_down could block indefinitely on send; partial-open TP >= 3 exports could drop pins early; packed checksum failures were misclassified; Announcer::spilled upserted before removing from; and empty rendezvous lists were not guarded in pool_peer.

Fixing each mechanism directly inside selene/src/pool/ and selene/src/shared/limits.rs hardens the client state machine without altering the gRPC protocol or runtime architecture.

What changed

  • Event-loop fairness (selene/src/pool/engine/mod.rs, selene/src/pool/conn.rs): Drain collect_outbound_fills() in Engine::pump_flow and replace the per-select resetting sleep(tick) in conn::serve with a persistent next_tick deadline.
  • Put/fence state machine (selene/src/pool/engine/writer.rs, selene/src/pool/engine/source.rs): Transition to Phase::Accepted at the top of on_put_accept, emit PutCancel + FenceAck(Drained) for late PutAccept on already-cancelled puts, reject accept.packed = true on raw puts, hold partial-open TP >= 3 export pins until opened peers report Done, and classify packed checksum failures as CopyChecksum.
  • Outbound backpressure & session recovery (selene/src/pool/conn.rs, selene/src/pool/engine/mod.rs): Pause flow_index when outbound channel capacity is <= 64, apply tx.reserve() backpressure instead of disconnecting on transient fullness, preserve queued fence-class messages in self.owed across session_lost, and strip IPv6 brackets in conn::dial.
  • Bounds, reconnect, and lifecycle safety (selene/src/shared/limits.rs, selene/src/pool/net.rs, selene/src/pool/engine/netio.rs, selene/src/pool/engine/requester.rs, selene/src/pool/agent.rs, selene/src/pool/announce.rs, selene/src/pool/peers.rs): Use checked/saturating math in staging_slots, Staging::planned_bytes, and Staging::new; verify max_window_bytes on reconnect in net_staging; add a 2s send timeout in RankAgent::wind_down and clear jobs/pending on quarantine; remove from before upserting to in Announcer::spilled; guard empty rendezvous lists in pool_peer.
  • Unit tests (selene/src/pool/engine/tests.rs): Added late_or_rejected_put_accept_always_emits_fence_ack_drained and session_lost_preserves_unsent_fence_messages_for_next_session.

Expected benefit and measured result

The pool client now makes steady progress under high message rates, never wedges the manager waiting on dropped fence acknowledgments, handles outbound gRPC saturation cleanly without reconnect storms, and rejects overflowing staging/window limits safely.

Supporting evidence

  • Standalone branch rebased onto post-#607 main (5df8edd3c):
    • RUSTFLAGS="-D warnings" cargo check --locked --manifest-path selene/Cargo.toml --all-targets --features codec,rdma and selene-manager --lib --bins: passed with 0 warnings.
    • cargo test --locked --release --manifest-path selene/Cargo.toml --features codec --lib: 542/542 passed.
  • Combined 4-PR validation & SM120/SM121 hardware qualification:
    • Live flare run + selene-manager pool retirement and cold-start pool-only restores on SM120 (cn5: Qwen3.8-Flash-Next TP1/TP2, GLM-5.3-Flash TP2/TP4, DeepSeek-V4.1-Flash-1017 TP4) and cross-host TCP streaming on GB10 (cn6–cn9, 300–400 stream windows across 3-node TP2 and 4-node TP4): 0 disconnects, 0 leaked pins, 0 quarantined bytes, bit-exact pos0 parity.
  • Material limitations: Live hardware qualification ran against the combined 4-PR stack before rebasing onto #496/#497/#607, and CPU tests were re-run after rebasing onto 5df8edd3c.

Discord: D-Rock

@yatesdr
yatesdr force-pushed the fix/selene-pool-client-reliability branch 3 times, most recently from 1e759b6 to bf4ee52 Compare November 29, 2026 17:27
The pool client engine and connection loop could starve outbound fills
and engine timers under active traffic, drop fence acknowledgments for
rejected or cancelled puts and lost sessions, livelock when resyncs
exceeded the outbound channel buffer, or overflow staging calculations
on untrusted manager limits.

- Drain completed host fills in `Engine::pump_flow` and replace the
  resetting per-select sleep in `conn::serve` with a persistent
  `next_tick` deadline (`selene/src/pool/engine/mod.rs`,
  `selene/src/pool/conn.rs`).
- Pause index resync/notice flow when the outbound gRPC channel lacks
  headroom, apply non-blocking `tx.reserve()` backpressure instead of
  disconnecting on transient channel fullness, and preserve queued
  `FenceAck`, `ExportEnd`, and `WindowReleased` messages in `owed` on
  session loss (`selene/src/pool/conn.rs`,
  `selene/src/pool/engine/mod.rs`).
- Transition puts to `Phase::Accepted` upon `PutAccept` so all local
  rejection branches emit `FenceAck(Drained)`, answer late `PutAccept`
  for already-cancelled puts with `PutCancel` + `FenceAck(Drained)`, and
  reject `accept.packed = true` for raw puts
  (`selene/src/pool/engine/writer.rs`).
- Use saturating/checked arithmetic in `staging_slots`,
  `Staging::planned_bytes`, and `Staging::new`, reject reconnects whose
  `max_window_bytes` exceeds registered staging, and strip IPv6 brackets
  when dialing the data channel (`selene/src/shared/limits.rs`,
  `selene/src/pool/net.rs`, `selene/src/pool/engine/netio.rs`,
  `selene/src/pool/conn.rs`).
- Bound `RankAgent::wind_down` goodbye sends with a timeout, clear
  `jobs`/`pending` on `Agent::quarantine`, retain pins until partially
  opened export peers report `Done`, report `CopyChecksum` on packed
  checksum failures, remove `from` before inserting `to` in
  `Announcer::spilled`, and guard empty rendezvous replies in
  `pool_peer` (`selene/src/pool/agent.rs`,
  `selene/src/pool/engine/source.rs`,
  `selene/src/pool/engine/requester.rs`, `selene/src/pool/announce.rs`,
  `selene/src/pool/peers.rs`).

Pool sessions no longer stall puts or timers under load, leak manager
put slots or staging windows on cancelled/rejected accepts, livelock
during large resyncs, or panic on invalid limits or rendezvous replies.

Validated on GB10 (`cn6`):
- `cargo test --manifest-path selene/Cargo.toml --features codec --release`: 515/515 lib + 1/1 `mixed_codec_root` passed (including new tests `late_or_rejected_put_accept_always_emits_fence_ack_drained`, `session_lost_preserves_unsent_fence_messages_for_next_session`, and `staging_slots_saturates_instead_of_overflowing`).
- `cargo test --manifest-path selene-manager/Cargo.toml --release --lib --test client --test offload --test packed --test pool_claims --test pool_store --test pool_net`: 180/180 lib + 149/149 integration tests passed across `client`, `offload`, `packed`, `pool_claims`, `pool_store`, and `pool_net`.

Signed-off-by: yatesdr <6937857+yatesdr@users.noreply.github.com>
Design-Signed-Off-By: yatesdr; design-review=2e5b
@yatesdr
yatesdr force-pushed the fix/selene-pool-client-reliability branch from bf4ee52 to aac8f4f Compare November 29, 2026 17:31
@yatesdr
yatesdr merged commit 8d05b9b into NVIDIA:main Nov 29, 2026
2 of 3 checks passed
@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 611.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot

Copy link
Copy Markdown
Collaborator

Review Stopped

Auto-Review halted due to finding: It was already fixed another way (merged or on the main branch), or is no longer needed for another reason.
Value Proposition Report

@flare-autobot flare-autobot added area:selene Selene shared prefix-cache pool, protocol, manager, and transfers. bug Something isn't working performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness. labels Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:selene Selene shared prefix-cache pool, protocol, manager, and transfers. bug Something isn't working performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants